package me.zk.practice1.thread;


import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;

/**
 * @Author: zhang kai
 * @Date: 2021/12/18
 * @Description:
 */
public class DemoThread extends Thread {
    public static void main(String[] args) throws Exception {
        //1、继承Thread类
        Thread t1 = new DemoThread();
        //2、使用Runnable接口
        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
            //...
            }
        });
        //Thread t2 = new Thread(()->System.out.println(""));
        //3、使用Callable
        Future<String> future = new FutureTask<String>(new Callable<String>() {
            @Override
            public String call() {
                return null;
            }
        });
        t1.start();
        t2.start();

        future.get();
    }
    @Override
    public void run() {
        //...
    }
}
